from rest_framework import serializers
from apps.Basic_data.models import Units, Clients, Suppliers, Product, GoodsCategory


class BasicModelSerializer(serializers.ModelSerializer):
    """
    基础模型序列化器
    """

    class Meta:
        # 指定序列化的模型
        model = None
        # 指定序列化的字段，使用 "__all__" 表示包含所有字段
        fields = "__all__"


class BasicGoodsCategorySerializer(BasicModelSerializer):
    """
    商品分类序列化器
    """

    class Meta(BasicModelSerializer.Meta):
        model = GoodsCategory
        fields = "__all__"


class BasicUnitSerializer(BasicModelSerializer):
    """
    单位序列化器
    """

    class Meta(BasicModelSerializer.Meta):
        model = Units
        fields = "__all__"


# class BasicColorSerializer(BasicModelSerializer):
#     """
#     颜色序列化器
#     """
#
#     class Meta(BasicModelSerializer.Meta):
#         model = Colors
#         fields = "__all__"


class BasicClientSerializer(BasicModelSerializer):
    """
    客户序列化器
    """

    class Meta(BasicModelSerializer.Meta):
        model = Clients
        fields = "__all__"


class BasicSupplierSerializer(BasicModelSerializer):
    """
    供应商序列化器
    """

    class Meta(BasicModelSerializer.Meta):
        model = Suppliers
        fields = "__all__"


class BasicGoodsSerializer(BasicModelSerializer):
    """
    商品序列化器
    """
    # category = BasicGoodsCategorySerializer()
    # unit = BasicUnitSerializer()
    # supplier = BasicSupplierSerializer()

    class Meta(BasicModelSerializer.Meta):
        model = Product
        fields = "__all__"

